package com.isoft.illustrationsdraw.mapper;

import com.isoft.illustrationsdraw.entity.Illustration;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.data.repository.query.Param;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

@Mapper
public interface IllustrationMapper extends BaseMapper<Illustration> {
    @Select("""
        SELECT 
            i.* 
        FROM 
            illustrations i
        JOIN 
            users u
        ON 
            i.author_id = u.id
        WHERE 
            u.nickname = #{nickname}
        """)
    IPage<Illustration> selectIllustrationsByAuthorName(Page<Illustration> page, @Param("nickname") String nickname);
}
